package o;

import android.app.Activity;
import o.dio.c;

public class ezw {
    private static ezw ˎ;
    private Activity ˊ;
    private fad ˋ;
    private boolean ˏ = false;
    private boolean ॱ = false;
    private boolean ॱॱ;

    public static synchronized ezw ॱ() {
        ezw o_ezw;
        synchronized (ezw.class) {
            if (ˎ == null) {
                ˎ = new ezw();
            }
            o_ezw = ˎ;
        }
        return o_ezw;
    }

    public synchronized void ˎ(fad o_fad) {
        this.ˋ = o_fad;
    }

    public synchronized void ˋ(Activity activity, boolean z) {
        this.ˊ = activity;
        this.ॱॱ = z;
        this.ˏ = false;
        this.ॱ = false;
        diu ˊ = diu.ˊ();
        if (ˊ.ˎ()) {
            this.ॱ = true;
            this.ˏ = true;
            ezt.ˏ().ॱ();
            ˏ(0);
        } else {
            ˊ.ˏ(this.ˊ, new c(this) {
                final /* synthetic */ ezw ˎ;

                {
                    this.ˎ = r1;
                }

                public void ॱ(boolean z) {
                    this.ˎ.ॱ(this.ˎ.ˊ, z);
                }
            });
        }
    }

    public synchronized void ˋ(int i, boolean z) {
        this.ˏ = z;
        ˏ(i);
    }

    synchronized void ˊ(int i) {
        ˏ(i);
    }

    private synchronized void ˏ(int i) {
        if (this.ˏ) {
            if (!this.ॱ) {
                i = 2;
            }
            ˏ();
            if (!(this.ॱॱ || this.ˋ == null)) {
                try {
                    this.ˋ.ˎ(i);
                } catch (Exception e) {
                    Logger.e("GameServiceInitManager", "AIDL callback RemoteException");
                }
                ˎ();
            }
        } else {
            Logger.ˏ("GameServiceInitManager", "protocol has not checked");
        }
    }

    public synchronized void ˏ() {
        if (this.ˊ != null) {
            if (!this.ˊ.isFinishing()) {
                if (this.ˏ) {
                    this.ˊ.setResult(!this.ॱ ? 0 : 1, null);
                    this.ˊ.finish();
                    this.ˊ = null;
                } else if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceInitManager", "[closeActivity]protocol has not checked");
                }
            }
        }
    }

    public synchronized void ˎ() {
        if (this.ˋ != null) {
            this.ˋ = null;
        }
    }

    public synchronized boolean ˊ() {
        return this.ॱ;
    }

    private synchronized void ॱ(Activity activity, boolean z) {
        diu.ˊ().ˋ(activity);
        this.ˏ = true;
        if (z) {
            this.ॱ = true;
            ezt.ˏ().ॱ();
        } else {
            this.ॱ = false;
        }
        ˏ(0);
    }
}
